import java.net.InetAddress;
import java.net.UnknownHostException;

import javax.swing.JLabel;


public class ConnectionSetup {
String IP;
int port = 54321;
	
/*
 * Get IP of host machine
 */
	public String getIP(){
		try{
			InetAddress ip = InetAddress.getLocalHost();
			IP = ip.toString();
			for(int i = 0; i < IP.length(); i++){
				if(IP.charAt(i) == '/'){
					IP = IP.substring(i+1, IP.length());
					break;
				}
			}
		}
		catch(Exception e){
			e.printStackTrace();
		}
		return IP;
	}
	
	/*
	 * Default port is 54321
	 */
	public void setPort(String s){
		s.trim();
		int i = Integer.parseInt(s);
		port = i;
	}
	
	public int getPort(){
		return port;
	}
	
	public String getHostname(){
		String hostname = null;
		try {
			hostname = InetAddress.getLocalHost().getHostName();
		} catch (UnknownHostException e1) {
			e1.printStackTrace();
		}
		return hostname;
	}
	
}
